﻿namespace Molten;

public struct SignedDistance
{
    public double Distance;

    public double Dot;

    public SignedDistance()
    {
        Distance = -double.MaxValue;
        Dot = 1;
    }

    public SignedDistance(double dist, double dot)
    {
        Distance = dist;
        Dot = dot;
    }

    public static bool operator <(SignedDistance a, SignedDistance b)
    {
        return Math.Abs(a.Distance) < Math.Abs(b.Distance) || (Math.Abs(a.Distance) == Math.Abs(b.Distance) && a.Dot < b.Dot);
    }

    public static bool operator >(SignedDistance a, SignedDistance b)
    {
        return Math.Abs(a.Distance) > Math.Abs(b.Distance) || (Math.Abs(a.Distance) == Math.Abs(b.Distance) && a.Dot > b.Dot);
    }

    public static bool operator <=(SignedDistance a, SignedDistance b)
    {
        return Math.Abs(a.Distance) < Math.Abs(b.Distance) || (Math.Abs(a.Distance) == Math.Abs(b.Distance) && a.Dot <= b.Dot);
    }

    public static bool operator >=(SignedDistance a, SignedDistance b)
    {
        return Math.Abs(a.Distance) > Math.Abs(b.Distance) || (Math.Abs(a.Distance) == Math.Abs(b.Distance) && a.Dot >= b.Dot);
    }
}
